package com.ljsw.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ljsw.activity.R;
import com.ljsw.entity.gpk.NotcompeteNumState;

import java.util.List;

/**
 * Created by lianchao on 2020/10/15.
 */

public class PKReconcilAdapter extends BaseAdapter {

    private List<NotcompeteNumState> LockID;
    private Context mContext;



//    public PKReconcilAdapter(List<NotcompeteNumState> LockID, Context mContext, Callback mCallback) {
//        super();
//        this.LockID = LockID;
//        this.mContext = mContext;
//        this.mCallback = mCallback;
//    }
    public PKReconcilAdapter(List<NotcompeteNumState> LockID, Context mContext) {
        super();
        this.LockID = LockID;
        this.mContext = mContext;
    }


//    public interface Callback {
//        public void onClickbtn(View v);
//    }




    @Override
    public int getCount() {
        return LockID.size();
    }

    @Override
    public Object getItem(int position) {
        return LockID.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        PKReconcilAdapter.ViewHolder mviewHolder = null;
        if (mviewHolder == null) {
            mviewHolder = new PKReconcilAdapter.ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.pkreconciliation_list, null, false);
            TextView PKNo = (TextView) convertView.findViewById(R.id.PKReconcilia);
            TextView PKReconciliastate = (TextView) convertView.findViewById(R.id.PKReconciliastate);
            TextView PKReconciliainfo = (TextView) convertView.findViewById(R.id.PKReconciliainfo);
            mviewHolder.PKNo = PKNo;
            mviewHolder.PKReconciliastate = PKReconciliastate;
            mviewHolder.PKReconciliainfo = PKReconciliainfo;
            convertView.setTag(mviewHolder);
        } else {
            mviewHolder = (PKReconcilAdapter.ViewHolder) convertView.getTag();
            convertView.setTag(mviewHolder);
        }
        mviewHolder.PKNo.setText(LockID.get(position).getNotno());
        if (LockID.get(position).getState().equals("0")) {
            mviewHolder.PKReconciliastate.setText("未扫描");
        } else if (LockID.get(position).getState().equals("1")) {
            mviewHolder.PKReconciliastate.setText("已扫描");
        }
//        mviewHolder.PKReconciliaChange.setText(LockID.get(position).getPKReconcolChangeState());
//        mviewHolder.PKbtnChange.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                data1=  LockID.get(position).getNotno();
//                position1=position;
//            }
//        });
//        mviewHolder.PKbtnChange.setTag(position);
//        mviewHolder.mPosition = position;
        return convertView;
    }

    /***
     * 不给修改状态按钮添加点击事件
     */
    class ViewHolder {
        public int mPosition;
        private TextView PKNo;
        private TextView PKReconciliastate;
        private TextView PKReconciliainfo;
        private TextView PKbtnChange;//  按钮改变状态


    }

//    //响应按钮点击事件,调用子定义接口，并传入View
//    @Override
//    public void onClick(View v) {
//        mCallback.onClickbtn(v);
//
//    }

}
